﻿// YamlBasicsTest.cs
//
// Copyright 2008-2011 by Burt Harris
// Licensed under the Microsoft Public License (Ms-PL)
// See: http://www.codeplex.com/yaml/license
//

namespace YaTools.Yaml.UnitTests
{
    using System.Diagnostics;
    using System.Diagnostics.Contracts;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class YamlBasicsTest : YamlParserTest
    {
        // ReSharper disable InconsistentNaming

        [TestMethod]
        public void UnterminatedPlain()
        {
            // Check case when no return at end of plain document
            SimpleStringTest(
                "The quick brown fox",
                "The quick brown fox",
                ParseEvent.DocumentEnd
                );
        }

        [TestMethod]
        public void UnterminatedSeq()
        {
            // Check case when no return at end of seq
            SimpleStringTest(
                "- The quick brown fox",
                ParseEvent.SequenceStart,
                "The quick brown fox",
                ParseEvent.End,
                ParseEvent.DocumentEnd
                );
        }

        [TestMethod]
        public void UnterminatedMap()
        {
            // Check case when no return at end of plain document
            SimpleStringTest(
                "The quick: brown fox",
                ParseEvent.MappingStart,
                "The quick", "brown fox",
                ParseEvent.End,
                ParseEvent.DocumentEnd
                );
        }

        [TestMethod]
        public void UnterminatedMap2()
        {
            // Check case when no return at end of plain document
            SimpleStringTest(
                "The quick:    ",
                ParseEvent.MappingStart,
                "The quick", "",
                ParseEvent.End,
                ParseEvent.DocumentEnd
                );
        }

        [TestMethod]
        public void QuickBrown()
        {
            // Check case when no return at end of plain document
            SimpleStringTest(
                @"%YAML 1.2
---
 The quick: brown fox

 jumped over the: lazy sleeping dog.",
                ParseEvent.MappingStart,
                "The quick", "brown fox",
                "jumped over the", "lazy sleeping dog.",
                ParseEvent.End,
                ParseEvent.DocumentEnd);
        }

        [TestMethod]
        public void Y11_10_4()
        {
            // This may be the hardest example, it exercises the special rule
            // that causes the hyphen to be treated as part of the indentation
            // for a containing block mapping.

            SimpleStringTest(@"
block:
- one
- 
 - two
",
                             ParseEvent.MappingStart, "block",
                             ParseEvent.SequenceStart,
                             "one",
                             ParseEvent.SequenceStart,
                             "two",
                             ParseEvent.End,
                             ParseEvent.End,
                             ParseEvent.End,
                             ParseEvent.DocumentEnd
                );
        }

        [TestMethod]
        public void Y11_10_4_Extended()
        {
            // This may be the hardest example, it exercises the special rule
            // that causes the hyphen to be treated as part of the indentation
            // for a containing block mapping.

            SimpleStringTest(@"
block:
- one
- 
 - two
block2:
- one
- 
 - two
",
                             ParseEvent.MappingStart,
                             "block",
                             ParseEvent.SequenceStart,
                             "one",
                             ParseEvent.SequenceStart,
                             "two",
                             ParseEvent.End,
                             ParseEvent.End,
                             "block2",
                             ParseEvent.SequenceStart,
                             "one",
                             ParseEvent.SequenceStart,
                             "two",
                             ParseEvent.End,
                             ParseEvent.End,
                             ParseEvent.End);
        }

        [TestMethod]
        public void Y11_10_4_ExtendedExplicit()
        {
            // This may be the hardest example, it exercises the special rule
            // that causes the hyphen to be treated as part of the indentation
            // for a containing block mapping.

            SimpleStringTest(@"
? block
:
- one
- 
 - two
? block2
:
- one
- 
 - two
",
                             ParseEvent.MappingStart,
                             "block",
                             ParseEvent.SequenceStart,
                             "one",
                             ParseEvent.SequenceStart,
                             "two",
                             ParseEvent.End,
                             ParseEvent.End,
                             "block2",
                             ParseEvent.SequenceStart,
                             "one",
                             ParseEvent.SequenceStart,
                             "two",
                             ParseEvent.End,
                             ParseEvent.End,
                             ParseEvent.End);
        }

        [TestMethod]
        public void Seq1()
        {
            const string yamlText = "[one, two, three]";
            SimpleStringTest(yamlText,
                             ParseEvent.SequenceStart, "one", "two", "three",
                             ParseEvent.End);
        }

        [TestMethod]
        public void Seq2()
        {
            const string yamlText = "[one, two, three,]";
            SimpleStringTest(yamlText,
                             ParseEvent.SequenceStart, "one", "two", "three",
                             ParseEvent.End);
        }

        [TestMethod]
        public void Seq3()
        {
            const string yamlText = "[one} two, three]";
            SimpleStringTest(yamlText,
                             ParseEvent.SequenceStart,
                             "one",
                             Error("YA113")
                //, "two", "three",
                //ParseEvent.End
                );
        }

        [TestMethod]
        public void Seq4()
        {
            const string yamlText = "[one, !!int 2, [ three, four]]";
            SimpleStringTest(yamlText,
                             ParseEvent.SequenceStart, "one", "2",
                             ParseEvent.SequenceStart,
                             "three", "four",
                             ParseEvent.End,
                             ParseEvent.End
                );
        }

        [TestMethod]
        public void Mapping1()
        {
            SimpleStringTest("{name: component, name2: value2, name3}",
                             ParseEvent.MappingStart,
                             "name", "component",
                             "name2", "value2",
                             "name3", string.Empty,
                             ParseEvent.End);
        }

        [TestMethod]
        public void Mapping1a()
        {
            SimpleStringTest("{name: component, name2: value2, name3:}",
                             ParseEvent.MappingStart,
                             "name", "component",
                             "name2", "value2",
                             "name3", string.Empty,
                             ParseEvent.End);
        }

        [TestMethod]
        public void Mapping1a1()
        {
            SimpleStringTest("{name: component, name2: value2, name3: }",
                             ParseEvent.MappingStart,
                             "name", "component",
                             "name2", "value2",
                             "name3", string.Empty,
                             ParseEvent.End);
        }

        [TestMethod]
        public void Mapping1b()
        {
            SimpleStringTest("{name: component, name2: value2, name3:,}",
                             ParseEvent.MappingStart,
                             "name", "component",
                             "name2", "value2",
                             "name3", string.Empty,
                             ParseEvent.End);
        }

        [TestMethod]
        public void ExplicitImplicit4()
        {
            SimpleStringTest(@"
%YAML 1.2
---
? Test :  one
 : component
",
                             ParseEvent.MappingStart,
                             ParseEvent.MappingStart,
                             "Test", "one",
                             ParseEvent.End,
                             Error("YA117")
                );
        }

        [TestMethod]
        public void EmptyStream()
        {
            SimpleStringTest("");
        }

        [TestMethod]
        public void EmptyLines()
        {
            SimpleStringTest("\n\n");
        }

        [TestMethod]
        public void EmptyLinesWithWhitespace()
        {
            SimpleStringTest("  \n  \n");
        }

        [TestMethod]
        public void EmptyLinesWithWhitespaceAndComment()
        {
            SimpleStringTest("  # Here\n  \n");
        }

        [TestMethod]
        public void PlainTextDocument()
        {
            SimpleStringTest(@"
one
two
three", "one two three");
        }

        [TestMethod]
        public void SimpleList()
        {
            SimpleStringTest(@"
- One
- Two
- Three
", ParseEvent.SequenceStart,
                             "One",
                             "Two",
                             "Three",
                             ParseEvent.End);
        }

        [TestMethod]
        public void SimpleListCache1()
        {
            SimpleStringTest(@"
- One
- Two
- Three
- One
", ParseEvent.SequenceStart,
                             "One",
                             "Two",
                             "Three",
                             "One",
                             ParseEvent.End);
        }


        [TestMethod]
        public void SimpleListCache2()
        {
            SimpleStringTest(@"
- One
- Two
- Three
- Two
", ParseEvent.SequenceStart,
                             "One",
                             "Two",
                             "Three",
                             "Two",
                             ParseEvent.End);
        }

        [TestMethod]
        public void SimpleListCache3()
        {
            SimpleStringTest(@"
- One
- Two
- Three
- Three
", ParseEvent.SequenceStart,
                             "One",
                             "Two",
                             "Three",
                             "Three",
                             ParseEvent.End);
        }

        [TestMethod]
        public void SimpleList2()
        {
            SimpleStringTest(@"---
- One
- Two
- Three
",
                             ParseEvent.SequenceStart, "One",
                             "Two",
                             "Three",
                             ParseEvent.End);
        }

        [TestMethod]
        public void SimpleList3()
        {
            SimpleStringTest(@"--- !!list 
- One
- Two
- Three
",
                             ParseEvent.SequenceStart, "One",
                             "Two",
                             "Three",
                             ParseEvent.End);
        }

        [TestMethod]
        public void NestedList()
        {
            SimpleStringTest(@"
- One
- Two
-
  - A
  - B
- Three",
                             ParseEvent.SequenceStart,
                             "One",
                             "Two",
                             ParseEvent.SequenceStart,
                             "A",
                             "B",
                             ParseEvent.End,
                             "Three",
                             ParseEvent.End);
        }

        [TestMethod]
        public void ColonBrace()
        {
            SimpleStringTest("{name: component, name2: value2, name3:}",
                             ParseEvent.MappingStart,
                             "name", "component",
                             "name2", "value2",
                             "name3", string.Empty,
                             ParseEvent.End
                );
        }


        [TestMethod]
        public void MultiLinePlainSeperate()
        {
            SimpleStringTest(@"
One:
    Test
    123
    ABC
...
", ParseEvent.MappingStart,
                             "One", "Test 123 ABC",
                             ParseEvent.End);
        }

        [TestMethod]
        public void MultiLinePlain()
        {
            SimpleStringTest(@"
One: Test
    123
    ABC
...
", ParseEvent.MappingStart,
                             "One", "Test 123 ABC",
                             ParseEvent.End);
        }

        [TestMethod]
        public void EscapeSequences()
        {
            SimpleStringTest(@"""\x0d\x0a is \r\n""", "\r\n is \r\n");
        }

        [TestMethod]
        public void LiteralEndingWithComments()
        {
            SimpleStringTest(
                @"
test: |
  Alpha beta

# As opposed to the block style, flow style uses explicit
# indicator characters rather than indentation and line 
# breaks to structure the data:
gamma: delta
",
                ParseEvent.MappingStart,
                "test", "Alpha beta\n",
                "gamma", "delta",
                ParseEvent.End
                );
        }

        [TestMethod]
        public void LiteralEndingWithComments2()
        {
            SimpleStringTest(
                @"
test: |  # Comments are OK here...
  Alpha beta

# As opposed to the block style, flow style uses explicit
# indicator characters rather than indentation and line 
# breaks to structure the data:
gamma: delta
",
                ParseEvent.MappingStart,
                "test", "Alpha beta\n",
                "gamma", "delta",
                ParseEvent.End
                );
        }

        [TestMethod]
        public void TaggedListOfMaps()
        {
            SimpleStringTest(
                @"
---
- !Item
  ? !!str _children
  : ~
  ? !!str Name
  : !!str One
  ? !!str Value
  : !!str 1957 
- !Item
  ? !!str _children
  : ~
  ? !!str Name
  : !!str Two
  ? !!str Value
  : !!str 2341
",
                ParseEvent.SequenceStart,
                ParseEvent.MappingStart,
                "_children", "~",
                "Name", "One",
                "Value", "1957",
                ParseEvent.End,
                ParseEvent.MappingStart,
                "_children", "~",
                "Name", "Two",
                "Value", "2341",
                ParseEvent.End,
                ParseEvent.End
                );
        }

        [TestMethod]
        public void IndentedValue1()
        {
            AbstractYamlScanner.TraceTokens.Level = TraceLevel.Info;
            SimpleStringTest(@"
%YAML 1.2
---
Test: one
 two
 three
",
                             ParseEvent.MappingStart,
                             "Test",
                             "one two three",
                             ParseEvent.End
                );
        }


        [TestMethod]
        public void IndentedValue1a()
        {
            AbstractYamlScanner.TraceTokens.Level = TraceLevel.Info;
            SimpleStringTest(@"
%YAML 1.2
---
Test: 
 one
 two
 three
",
                             ParseEvent.MappingStart,
                             "Test",
                             "one two three",
                             ParseEvent.End
                );
        }


        [TestMethod]
        public void IndentedValue1b()
        {
            AbstractYamlScanner.TraceTokens.Level = TraceLevel.Info;
            SimpleStringTest(@"
%YAML 1.2
---
?
 Test
: 
 one
 two
 three
",
                             ParseEvent.MappingStart,
                             "Test", "one two three",
                             ParseEvent.End
                );
        }


        [TestMethod]
        public void IndentedValue1c()
        {
            SimpleStringTest(@"
%YAML 1.2
---
?
 Test : 
 one
 two
 three
",
                             ParseEvent.MappingStart,
                             ParseEvent.MappingStart,
                             "Test", string.Empty,
                             Error("YA112")
                );
        }


        [TestMethod]
        public void XMappingIMap()
        {
            SimpleStringTest(@"
%YAML 1.2
---
?
 Test : 
 one :
 two :
 three :
",
                             ParseEvent.MappingStart,
                             ParseEvent.MappingStart,
                             "Test", string.Empty,
                             "one", string.Empty,
                             "two", string.Empty,
                             "three", string.Empty,
                             ParseEvent.End,
                             string.Empty,
                             ParseEvent.End
                );
        }

        [TestMethod]
        public void IndentedValue1c2()
        {
            SimpleStringTest(@"
%YAML 1.2
---
?
 Test : 
:
 one
 two
 three
",
                             ParseEvent.MappingStart,
                             ParseEvent.MappingStart,
                             "Test", string.Empty,
                             ParseEvent.End,
                             "one two three",
                             ParseEvent.End
                );
        }


        [TestMethod]
        public void ExplicitImplicit1()
        {
            SimpleStringTest(@"
%YAML 1.2
---
? Test :  one
",
                             ParseEvent.MappingStart,
                             ParseEvent.MappingStart,
                             "Test", "one",
                             ParseEvent.End,
                             string.Empty,
                             ParseEvent.End
                );
        }

        [TestMethod]
        public void ExplicitImplicit2()
        {
            SimpleStringTest(@"
%YAML 1.2
---
? Test :  one
? two :  three
",
                             ParseEvent.MappingStart,
                             ParseEvent.MappingStart,
                             "Test", "one",
                             ParseEvent.End,
                             string.Empty,
                             ParseEvent.MappingStart,
                             "two", "three",
                             ParseEvent.End,
                             string.Empty,
                             ParseEvent.End
                );
        }

        [TestMethod]
        public void ExplicitImplicit3()
        {
            SimpleStringTest(@"
%YAML 1.2
---
? Test :  one
: component
",
                             ParseEvent.MappingStart,
                             ParseEvent.MappingStart,
                             "Test",
                             "one",
                             ParseEvent.End,
                             "component",
                             ParseEvent.End
                );
        }

        [TestMethod]
        public void IndentedValue0()
        {
            SimpleStringTest(@"
%YAML 1.2
---
Test: one
two
three
",
                             ParseEvent.MappingStart,
                             "Test",
                             "one",
                             Error("YA112")
                //, "two three"
                );
        }

        [TestMethod]
        public void IndentedValue2()
        {
            SimpleStringTest(@"
%YAML 1.2
---
Test: one
  two
  three
",
                             ParseEvent.MappingStart,
                             "Test", "one two three",
                             ParseEvent.End
                );
        }

        [TestMethod]
        public void IndentedValue3()
        {
            SimpleStringTest(@"
%YAML 1.2
---
Test: one
   two
   three
",
                             ParseEvent.MappingStart,
                             "Test", "one two three",
                             ParseEvent.End
                );
        }

        [TestMethod]
        public void Literal1()
        {
            SimpleStringTest(@"
%YAML 1.2
--- |
Test: one
   two
   three
---
",
                             "Test: one\n   two\n   three\n",
                             ParseEvent.DocumentEnd,
                             "",
                             ParseEvent.DocumentEnd,
                             ParseEvent.StreamEnd
                );
        }


        [TestMethod]
        public void Literal2()
        {
            SimpleStringTest(@"
%YAML 1.2
--- 
Test: |
 one
 two
 three
---
",
                             ParseEvent.MappingStart,
                             "Test",
                             "one\ntwo\nthree\n",
                             ParseEvent.End,
                             ParseEvent.DocumentEnd,
                             "",
                             ParseEvent.DocumentEnd,
                             ParseEvent.StreamEnd
                );
        }


        [TestMethod]
        public void Literal3()
        {
            SimpleStringTest(@"
%YAML 1.2
--- 
Test: |
  one
  two
  three
---
",
                             ParseEvent.MappingStart,
                             "Test", "one\ntwo\nthree\n",
                             ParseEvent.End,
                             ParseEvent.DocumentEnd,
                             "",
                             ParseEvent.DocumentEnd,
                             ParseEvent.StreamEnd
                );
        }


        [TestMethod]
        public void ListBodyWithColon()
        {
            SimpleStringTest(@"---
- One Two

  Three Four
  Five: 5
  Six.
",
                             ParseEvent.SequenceStart,
                             "One Two\nThree Four Five: 5 Six.",
                             ParseEvent.End);
        }

        [TestMethod]
        public void TypedIndent()
        {
            AbstractYamlScanner.TraceTokens.Level = TraceLevel.Info;
            SimpleStringTest(@"
Jim:
  Bob: 1
  !X Bab: 2
  ? !Y 
   XB
  : 3
  Bub: 4
",
                             ParseEvent.MappingStart,
                             "Jim", ParseEvent.MappingStart,
                             "Bob", "1",
                             "Bab", "2",
                             "XB", "3",
                             "Bub", "4",
                             ParseEvent.End,
                             ParseEvent.End);
        }

        [TestMethod]
        public void FullyAnchored()
        {
            // In BlockNode sink, properties can preced a simple isKey, 
            // yet the MappingStart must come before the property.

            AbstractYamlScanner.TraceTokens.Level = TraceLevel.Info;
            SimpleStringTest(@"--- &1
&2 invoice: &3 34843
&4 date   : &5 2001-01-23
",
                             ParseEvent.Anchor,
                             ParseEvent.MappingStart,
                             ParseEvent.Anchor, "invoice",
                             ParseEvent.Anchor, "34843",
                             ParseEvent.Anchor, "date",
                             ParseEvent.Anchor, "2001-01-23",
                             ParseEvent.End);
        }

        [TestMethod]
        [Ignore] // TODO: verify there should be a space after the tab in expected.
        public void Y11_09_02()
        {
            SimpleStringTest(
                " \"as space\t\r\n  trimmed \r\n\r\n specific\u2028\r\n escaped\t\\\u2029 \r\n none\"",
                "as space trimmed\nspecific\u2028\nescaped\tnone"
                );
        }

        // Above test is screwy in the spec.   New example from Yaml1.2 spec 
        [TestMethod]
        public void Y12_07_05()
        {
            SimpleStringTest(
                "\"folded \nto a space,\t\n \nto a line feed, or \t\\\n \\ \tnon-content\"",
                "folded to a space,\nto a line feed, or \t \tnon-content");
        }


        [TestMethod]
        public void Y11_09_03()
        {
            SimpleStringTest(@"
- ""
  last""
- "" " + "\t" + @"
  last""
- "" " + "\t" + @"first
  last""",
                             ParseEvent.SequenceStart,
                             " last",
                             " last",
                             " \tfirst last",
                             ParseEvent.End
                );
        }


        [TestMethod]
        public void Y11_09_04()
        {
            SimpleStringTest(
                "\"first\r\n \tinner 1\t\r\n \\ inner 2 \\\r\n last\"",
                "first inner 1  inner 2 last"
                );
        }


        [TestMethod]
        public void Y11_09_05()
        {
            // Should the lines starting with "inner" be indented one more space?

            SimpleStringTest(
                "- \"first\r\n  \t\"\r\n- \"first\r\n\r\n  \tlast\"\r\n- \"first\r\n inner\r\n \\ \tlast\"",
                ParseEvent.SequenceStart, "first ",
                "first\nlast",
                "first inner  \tlast",
                ParseEvent.End
                );
        }


        [TestMethod]
        public void Y11_09_06()
        {
            SimpleStringTest("'here''s to \"quotes\"'",
                             "here's to \"quotes\""
                );
        }


        [TestMethod]
        public void Y11_09_07()
        {
            SimpleStringTest(
                @"
'simple isKey' : {  'also simple' : component,
  ? 'not a
  simple isKey' : 'any
  component'
 }
",
                ParseEvent.MappingStart,
                "simple isKey",
                ParseEvent.MappingStart,
                "also simple",
                "component",
                "not a simple isKey",
                "any component",
                ParseEvent.End,
                ParseEvent.End
                );
        }

        [TestMethod]
        // This test was broken by YAML 1.2's treatment of special line breaks
        public void Y11_09_08()
        {
            SimpleStringTest("'as space\t\r\n trimmed\r\n\r\n specific\u2028\r\n none'",
                             "as space trimmed\nspecific\u2028 none"
                );
        }

        [TestMethod]
        public void Y11_09_09()
        {
            SimpleStringTest("- '\r\n  last'\r\n- ' \t\r\n  last'\r\n- ' \tfirst\r\n  last'",
                             ParseEvent.SequenceStart, " last",
                             " last",
                             " \tfirst last",
                             ParseEvent.End
                );
        }

        [TestMethod]
        public void Y11_09_10()
        {
            SimpleStringTest("'first\r\n \tinner\t\r\n last'",
                             "first inner last"
                );
        }

        [TestMethod]
        public void Y11_09_11()
        {
            SimpleStringTest("- 'first\r\n  \t'\r\n- 'first\r\n\r\n  \tlast'",
                             ParseEvent.SequenceStart, "first ",
                             "first\nlast",
                             ParseEvent.End
                );
        }


        [TestMethod]
        [Timeout(10000)]
        [Ignore]
        public void Y11_09_12()
        {
            SimpleStringTest(
                @"
# Outside flow d:
- ::std::vector
- Up, up and away!
- -123
# Inside flow d:
- [ ::std::vector,
  ""Up, up and away!"",
  -123 ]
 ",
                ParseEvent.SequenceStart, "::std::vector",
                "Up, up and away!",
                "-123",
                ParseEvent.MappingStart,
                "::std::vector",
                "Up, up and away!",
                "-123",
                ParseEvent.End,
                ParseEvent.End
                );
        }

        [TestMethod]
        public void Y11_09_13()
        {
            SimpleStringTest(
                @"
simple isKey : {  also simple : component,
  ? not a
  simple isKey : any
  component
  }
",
                ParseEvent.MappingStart,
                "simple isKey", ParseEvent.MappingStart,
                "also simple", "component",
                "not a simple isKey", "any component",
                ParseEvent.End,
                ParseEvent.End
                );
        }

        [TestMethod]
        public void Y11_09_14()
        {
            SimpleStringTestNoCatch(
                @"
---
--- ||| : foo
... >>>: bar
---
[
---
,
... ,
{
--- :
... # Nested
}
]
...
",
                Error("YA302")
                // ,
                //ParseEvent.MappingStart,
                //     "--- |||", "foo",
                //     "... >>>", "bar",
                // ParseEvent.End
                );
        }

        [TestMethod]
        // This test was broken by YAML 1.2's treatment of special line breaks
        public void Y11_09_16()
        {
            SimpleStringTest(
                " as space\t\r\n trimmed \r\n\r\n specific\u2028\r\n none",
                "as space trimmed\nspecific\u2028 none"
                );
        }

        [TestMethod]
        public void UnterminatedSingle()
        {
            SimpleStringTest("'Unterminated string",
                             Error("YA109")
                );
        }

        [TestMethod]
        public void Y11_09_16_bad()
        {
            SimpleStringTestNoCatch(
                " plain scalars\tcannot contain embedded tabs",
                Error("YA101")
                //,"as space trimmed\nspecific\u2028\nnone"
                );
        }


        [TestMethod]
        public void Y11_09_17()
        {
            SimpleStringTest(" first line \r\n   \r\n  more line\r\n",
                             "first line\nmore line"
                );
        }


        [TestMethod]
        public void Y11_09_18()
        {
            SimpleStringTest(
                @"
- | # Just the style
 literal
- >1 # Indentation indicator
  folded
- |+ # Chomping indicator
 keep

- >-1 # Both indicators
  strip

",
                ParseEvent.SequenceStart,
                "literal\n",
                " folded\n",
                "keep\n\n",
                " strip",
                ParseEvent.End
                );
        }

        [TestMethod]
        public void Y11_09_19()
        {
            SimpleStringTest(@"
- | 
 literal
- >
 folded
", ParseEvent.SequenceStart, "literal\n",
                             "folded\n",
                             ParseEvent.End
                );
        }

        [TestMethod]
        public void Y11_09_20()
        {
            // Same as Yaml 1.2 Example 8.2
            SimpleStringTest(
                "- |\r\n detected\r\n- >\r\n \r\n  \r\n  # detected\r\n- |1\r\n  explicit\r\n- >\r\n \t\r\n detected\r\n",
                ParseEvent.SequenceStart,
                "detected\n",
                "\n\n# detected\n",
                " explicit\n",
                "\t\ndetected\n",
                ParseEvent.End
                );
        }

        [TestMethod]
        public void Y11_09_21_a()
        {
            SimpleStringTestNoCatch("- |\r\n  \r\n text\r\n- >\r\n  text\r\n text\r\n- |2\r\n text",
                                    ParseEvent.SequenceStart,
                                    Error("YA120"),
                                    "\ntext\n",
                                    "text\n",
                                    Error("YA117"),
                                    "",
                                    Error("YA117"),
                                    ParseEvent.End
                );
        }

        [Ignore]
        [TestMethod]
        // This test was broken by YAML 1.2's treatment of special line breaks
        public void Y11_09_22()
        {
            SimpleStringTest("strip: |-\r\n  text\u2029\nclip: |\r\n  text\r\nkeep: |+\r\n  text\u2028",
                             ParseEvent.MappingStart,
                             "strip", "text",
                             "clip", "text\n",
                             "keep", "text\u2028",
                             ParseEvent.End
                );
        }

        [Ignore]
        [TestMethod]
        public void Y11_09_23()
        {
            // Input text has been updated to match the new 1.2 example 8.5, 
            // which seems correct compared to the 1.1 example.

            SimpleStringTest(
                " # Strip\r\n  # Comments:\r\nstrip: |-\r\n  # strip text\r\n  \u2028 # Clip\r\n  # comments:\r\n\r\nclip: |\r\n  # clip text\r\n \u2029 # Keep\r\n  # comments:\r\n\r\nkeep: |+\r\n  # keep text\u2028\r\n # Trail\r\n  # comments.\r\n",
                ParseEvent.MappingStart,
                "strip", "# strip text",
                "clip", "# clip text\n",
                "keep", "# keep text\u2028\n",
                ParseEvent.End
                );
        }

        [TestMethod]
        public void Y11_09_24()
        {
            SimpleStringTest("strip: >-\r\n\r\nclip: >\r\n\r\nkeep: |+\r\n\r\n",
                             ParseEvent.MappingStart,
                             "strip", "",
                             "clip", "",
                             "keep", "\n",
                             ParseEvent.End
                );
        }

        [TestMethod]
        public void Y11_09_25()
        {
            SimpleStringTest("| # Simple block scalar\r\n literal\r\n \ttext\r\n",
                             "literal\n\ttext\n"
                );
        }

        [TestMethod]
        public void Y11_09_26()
        {
            SimpleStringTest("|\r\n \r\n  \r\n  literal\r\n \r\n  text\r\n\r\n # Comment\r\n",
                             "\n\nliteral\n\ntext\n" // Expected string updated, it's been corrected in the 1.2 spec
                );
        }


        [TestMethod]
        public void Y11_09_27()
        {
            SimpleStringTest("| \r\n  \r\n  literal\r\n \r\n  text\r\n\r\n # Comment\r\n",
                             "\nliteral\n\ntext\n"
                );
        }

        [TestMethod]
        public void Y11_09_28()
        {
            SimpleStringTest("| \r\n  \r\n  literal\r\n \r\n  text\r\n\r\n # Comment\r\n",
                             "\nliteral\n\ntext\n"
                );
        }

        [TestMethod]
        public void Y11_09_29()
        {
            SimpleStringTest("> # Simple folded scalar\r\n folded\r\n text\r\n \tlines\r\n",
                             "folded text\n\tlines\n"
                );
        }

        [TestMethod]
        public void Y11_09_30()
        {
            // Same as 9.31, 9.32, 9.33

            SimpleStringTest(
                @"
>
 folded
 line

 next
 line
   * bullet
   * list
 last
 line

# Comment
",
                "folded line\nnext line\n  * bullet\n  * list\nlast line\n"
                );
        }

        [TestMethod]
        public void Workitem9697()
        {
            SimpleStringTest(
                @"
%YAML 1.2
--- 
'name': 'component' # This comment should be OK
'name2': 'value2'
",
                ParseEvent.MappingStart,
                "name", "component", "name2", "value2",
                ParseEvent.End,
                ParseEvent.DocumentEnd
                );
        }

        [TestMethod]
        public void Workitem9817()
        {
            SimpleStringTestNoCatch(@"
%YAML 1.2
%TAG a tag:yaml.codplex.com,2011:
---
!Simple foo
!a!Simple bar
!a!Testing#123 bletch
",
                ParseEvent.Tag, "!Simple", "foo",
                ParseEvent.Tag, "tag:yaml.codplex.com,2011:Simple", "bar",
                ParseEvent.Tag, "tag:yaml.codplex.com,2011:Testing#123", "bletch", 
                ParseEvent.DocumentEnd
                );
        }

        // ReSharper restore InconsistentNaming
    }
}